package main.java.indi.zyj.hot100;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class _48_subsets {

    List<List<Integer>> res = new ArrayList<>();
    LinkedList<Integer> path = new LinkedList<>();

    public List<List<Integer>> subsets(int[] nums) {
        if (nums == null || nums.length == 0) return res;
        backtrack(nums, 0);
        return res;
    }

    public void backtrack(int[] nums, int start) {
        res.add(new ArrayList<>(path));
        for (int i = start; i < nums.length; i++) {
            path.addLast(nums[i]);
            backtrack(nums, start + 1);
            path.removeLast();
        }
    }



}
